import { defHttp } from '/@/utils/http/axios';
import { LoginParams, LoginResultModel, GetUserInfoModel } from './model/userModel';

import { ErrorMessageMode } from '/#/axios';
import { any } from 'vue-types';

enum Api {
  Login = '/v1/company/staff/login',
  Logout = '/logout',
  GetUserInfo = '/getUserInfo',
  GetPermCode = '/v1/sms/captcha',
}

/**
 * @description: user login api
 */
export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<any>(
    {
      url: Api.Login,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description: getUserInfo
 */
export function getUserInfo() {
  return localStorage.getItem('userInfor');
}

export function getPermCode(params: any) {
  return defHttp.post<string[]>({ url: Api.GetPermCode, params: params });
}

export function doLogout() {
  localStorage.removeItem('userInfor');
  localStorage.removeItem('token');
  return true;
}
